<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            position: relative;
            width: 10px;
            /* top:0px;
            left: 0px; */
        }
    </style>
</head>
<body>
    <img src="../../textimg/b2.jpg" alt="">
    <script>
        var img = document.querySelector('img');
        document.addEventListener('mousemove',function(e){
            img.style.top = e.clientY + 'px';
            img.style.left = e.clientX + 'px';
        })
    </script>
    <script>
        //键盘事件
        document.addEventListener('keyup',function(){
            console.log('键盘抬起事件');
            
        })
        document.addEventListener('keydown',function(){
            console.log('键盘按下事件down');
            
        })
        document.addEventListener('keypress',function(){
            console.log('键盘按下事件press');//不能识别功能键
            
        })
        //执行顺序 keydown - keypress - keyup
    </script>
</body>
</html>